//
//  ActivityTableView.m
//  MyProject
//
//  Created by dllo on 15/11/2.
//  Copyright (c) 2015年 蓝鸥0825. All rights reserved.
//

#import "ActivityTableView.h"
#import "ActivityTableViewCell.h"
#import "ActViewController.h"

#define WIDTH self.frame.size.width
#define HEIGHT self.frame.size.height
@implementation ActivityTableView

- (instancetype)initWithFrame:(CGRect)frame{
    
    self = [super initWithFrame:frame];
    if (self) {
        [self create];
    }
    return self;
}


- (void)create{
    
    self.table = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT)];
    [self addSubview:self.table];
    self.table.rowHeight = HEIGHT / 2;
    self.table.dataSource = self;
    self.table.delegate = self;
    self.table.separatorStyle = UITableViewCellSeparatorStyleNone;
    
    
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.arrayActivity.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    static NSString *reuse = @"reuse";
    ActivityTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuse];
    if (!cell) {
        cell = [[ActivityTableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:reuse];
    }
    cell.modelActivity = self.arrayActivity[indexPath.row];
    return cell;
    
}



- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    ActViewController *actVC = [[ActViewController alloc] init];
    [self.VC.navigationController pushViewController:actVC animated:YES];
    actVC.modelAct = self.arrayActivity[indexPath.row];
    
}





@end











